var zigzagLevelOrder = function(root) {

  var zigzagLevelOrder = function(root) {
    if(!root){
      return [];
    }
    let arr = [root];
    let res = [];
    let isodd = false;
    while(arr.length){
      let row = []; //当前层
      for(let i = 0;i<arr.length;i++){
        let node = arr.shift(); //取出
        row.push(node.val);// 当前层
        if(node.left) arr.push(node.left);
        if(node.right) arr.push(node.right);

      }
      if(!isodd){
        res.push(row.reverse());
      }else{
        res.push(row)
      }
    }
    return res;
  };


};

console.log(zigzagLevelOrder([3, 9, 20, null, null, 15, 7]));
